import store from '../store'
import vue from 'vue'
// 手机银行登录回调
window.loginResult = function (result, key) {
    pushBankData(2, key, result)
}

//手机银行OCR返回事件
window.IDOCRResult = function (result, key) {
    pushBankData(3, key, result)
}

//手机银行拍照事件
window.getPictureResult = function (result, key) {
    pushBankData(4, key, result)
}

//活体返回事件
window.faceRecognitionResult = function (result, key) {
    pushBankData(5, key, result)
}

//通讯录返回事件
window.contactsResult = function (result, key) {
    pushBankData(6, key, result)
}

/*
 * @param {*} typeCode  1:返回事件  2:登录回调  3:COR身份证 4:拍照 5：活体 6通讯录
 * @param {*} key 密钥
 * @param {*} result  密文
 */
function pushBankData (typeCode, key, result) {
    var jData = {
        data: result,
        key: key,
        type: typeCode
    }
    store.commit('DATA_INTERACTION', jData)
}

// 手机银行回调返回方法
window.back = function () {
    vue.Dialog.confirm({
        title: '温馨提示',
        message: '是否退出福祥e贷进件流程'
    }).then(() => {
        
        var userAgent = navigator.userAgent.toLowerCase()
        if (userAgent.match(/android_hnrcc/i) == 'android_hnrcc' || userAgent.match(/ios_hnrcc/i) == 'ios_hnrcc') {
            NXYJS.goHomePage()// eslint-disable-line
        } else {
            WeixinJSBridge.call('closeWindow')// eslint-disable-line
        }
    }).catch(() => {
       
    })
}